<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://api.icathia.cn/layui/css/layui.css" />
<script src="https://api.icathia.cn/layui/layui.js" type="text/javascript"></script>
<script src="https://api.icathia.cn/layer/layer.js" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" type="text/javascript"></script>
<body>
<div class="container">

<%--    action="${pageContext.request.contextPath}/student/addStudent" method="post"--%>

    <form  action="" method="post" style="margin-top: 15px" class="layui-form" onsubmit="return false">


        <div class="layui-form-item">
            <label class="layui-form-label">ID</label>
            <div class="layui-input-block">
                <input type="text" name="stuID" required  lay-verify="required" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">学号</label>
            <div class="layui-input-block">
                <input type="text" name="stuNo" required  lay-verify="required" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input type="text" name="name1" required  lay-verify="required" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">生日</label>
            <div class="layui-input-block">
                <input type="text" name="birthday" required  lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">班级</label>
            <div class="layui-input-block">
                <input type="text" name="stuClass" required  lay-verify="required" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <input type="text" name="gender" required  lay-verify="required" class="layui-input">
            </div>
        </div>



        <div class="form-group">
            <input type="submit" lay-submit="" lay-filter="edit" class="layui-btn layui-btn-fluid"value="提交" id="pointsform">
        </div>


</form>
</div>
<script type="text/javascript">
    layui.use(['laydate','form'], function(){
        var $ = layui.jquery,
            form = layui.form
            ,layer = layui.layer,
            laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#birthday' //指定元素
        });

        //编辑提交事件
        form.on('submit(edit)', function(data){

            //提交编辑的数据到后端
            $.post('${pageContext.request.contextPath}/student/addStudent', data.field,function(date){
                alert("提交成功");
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //刷新父页面
                parent.location.reload();//关闭之前刷新父页面
                //关闭当前frame
                parent.layer.close(index);
            })
        });
    });

</script>

</body>
</html>
